package com.linkhub.oms.dao.mpservice.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkhub.oms.dao.mapper.LocalProductCombinationInfoEntityMapper;
import com.linkhub.oms.dao.mpservice.ILocalProductCombinationInfoService;
import com.linkhub.oms.entity.LocalProductCombinationInfoEntity;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 本地产品组合产品信息表 服务实现类
 * </p>
 *
 * @author Jaycle
 * @version 1.0.0
 * @Description LocalProductAmountDeclaresInfoEntityServiceImpl.java
 * @createTime 2024/06/18 23:52
 */
@Service
public class LocalProductCombinationInfoImpl extends ServiceImpl<LocalProductCombinationInfoEntityMapper, LocalProductCombinationInfoEntity>
        implements ILocalProductCombinationInfoService {

    @Override
    public void deleteLocalProductCombinationInfo( String userId, String skuId ) {
        lambdaUpdate()
                .eq(LocalProductCombinationInfoEntity::getUserId, userId)
                .eq(LocalProductCombinationInfoEntity::getSkuId, skuId)
                .remove();
    }

    @Override
    public void saveLocalProductCombinationInfo( List<LocalProductCombinationInfoEntity> localProductCombinationInfoEntities ) {
        if (localProductCombinationInfoEntities != null && !localProductCombinationInfoEntities.isEmpty()) {
            // Save the entities in batch
            saveBatch(localProductCombinationInfoEntities);
        }
    }

    @Override
    public List<LocalProductCombinationInfoEntity> queryCombinationInfoBySkuId( String userId, String skuId ) {
        return lambdaQuery()
                .eq(LocalProductCombinationInfoEntity::getUserId, userId)
                .eq(LocalProductCombinationInfoEntity::getSkuId, skuId)
                .list();
    }
}
